<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{$category.name} {$category.page_title} {$site_info.site_name|default=''}</title>
<meta name="keywords" content="{$category.page_keywords},{$site_info.site_seo_keywords|default=''}"/>
<meta name="description" content="{$category.page_description},{$site_info.site_seo_description|default=''}">
<include file="public@head"/>

</head>
<body>
    <include file='public@nav'/>
    <include file="public@banner"/>
    <div class="main layout clearfix">

        <include file="public@category"/>

        <div class="oright fr">
            
            <include file="public@breadcrumb"/>

            <php>
                $limit = empty($theme_vars['data_limit']) ? 6 : $theme_vars['data_limit'];
                if( $limit <= 0 ){
                    $limit = 6;
                }

                /*顶级分类ID*/
                $top_category_id = empty($theme_vars['top_category_id']) ? 1 : $theme_vars['top_category_id'];
                
                /*顶级分类的子分类*/
                $categorys = sp_get_child_terms($top_category_id);
                
                /*当前分类cat_id是否为顶级分类,若是则查询该分类及其子分类下的文章,否则仅查询该分类下的文章*/
                $ids       = [$cat_id];
                $all_class = '';
                if( $top_category_id == $cat_id ){
                    $all_class = 'on';
                    foreach ($categorys as $v) {
                        $ids[] = $v['id'];
                    }
                }else{
                    $new_category = model('portal_category')
                                 -> where('id', $top_category_id)
                                 -> order('list_order asc,id desc')
                                 -> find();
                    $category['name']        = $new_category['name'];
                    $category['description'] = $new_category['description'];
                }
            </php>

            <div class="content">
                <div class="qlist">
                    <ul>
                        <php>
                            $order = SO;
                        </php>

                        <portal:articles item="vo" order="$order" page="6" field="post.id,post_title,post_content,published_time,post_excerpt,post.more,category_id"
                                     relation="categories"
                                     categoryIds="$ids"
                                     returnVarName="articles_data">

                            <li <if condition="$i eq 1">class="on"</if>>
                                <div class="top clearfix">
                                    <span>Q</span>
                                    <div class="txt clearfix">
                                         {$vo.post_title}
                                        <i class="iconfont fr">&#xe634;</i>
                                    </div>
                                    
                                </div>
                                <div class="bot" <if condition="$i eq 1">style="display:block"</if>>
                                     {$vo.post_content}
                                </div>
                            </li>
                        </portal:articles>
                        
                    </ul>
                    <div class="pages">
                        <page/>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <include file='public@footer'/>
</body>
</html>

<include file='public@scripts'/>

<script type="text/javascript">
    $(function(){
        $('.qlist ul li').click(function(){
            if($(this).hasClass('on')){
                $(this).children('.top').find('i').html('&#xe74d;')
                $(this).children('.bot').slideUp()
                $(this).removeClass('on')
            }else{
                $(this).children('.top').find('i').html('&#xe634;')
                $(this).siblings().children('.top').find('i').html('&#xe74d;')
                $(this).children('.bot').slideDown()
                $(this).addClass('on').siblings().removeClass('on')
                $(this).siblings().children('.bot').slideUp()
            }
        })
    })
</script>
